using System;
using System.Collections.Specialized;
using ZP.Data;
using Kwan.Data;

namespace ZP.Service
{
    public static class UserQuery
	{
        public static Expression MakeSearchWhere(NameValueCollection ps)
		{
            Expression exp = new Expression();

            string propName = "EntityID";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TUser.entityID == ps[propName];

            propName = "RoleID";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TUser.roleID == ps[propName];
            propName = "LoginTime";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TUser.loginTime == ps[propName];
            propName = "CompanyID";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TUser.companyID == ps[propName];
            propName = "ResumeID";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TUser.resumeID == ps[propName];
            propName = "Email";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TUser.email > ps[propName];
            propName = "Scale";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TUser.scale == ps[propName];
            propName = "Password";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TUser.password == ps[propName];
            propName = "UserName";
            if (!string.IsNullOrEmpty(ps[propName]))
                exp &= TUser.userName.Like("%" + ps[propName] + "%");

            return exp;
		}
	}
}